package Singleton;

import javax.imageio.ImageTypeSpecifier;
import java.util.Hashtable;

public class MyFruitStore {
    private static Hashtable fruitTable;
    private static MyFruitStore myFruitStore;

    private MyFruitStore()
    {
        fruitTable = new Hashtable<Integer, MyFruit>();
    }

    public static MyFruitStore getInstance()
    {
        if(myFruitStore == null)
        {
            myFruitStore = new MyFruitStore();
        }
        return myFruitStore;
    }


    public void add(Integer key, MyFruit fruit)
    {
        fruitTable.put(key,fruit);
    }

    public MyFruit get(Integer key)
    {
        MyFruit fruit = (MyFruit)fruitTable.get(key);
        return (MyFruit) fruit.clone();
    }


}
